#include <math.h>
#include <stdio.h>
#include <time.h>

int main()
{

float b[100];

int max1=0,min1=101;
float max2=0,min2=1,sum1=0,sum2=0;

int a[100]={0};
int i, m;
for(i=0; i<100; i++)
{
        while(a[m=rand()%100]);
        a[m] = i;
}
for (i=0;i<100;i++)
{


if(a[i]!=0)
b[i]=1.0/a[i];
else
b[i]=0.0;
}
FILE *fp;
fp=fopen("m1","w");
if(fp!=NULL)
{
for(i=0;i<100;i++)
{
fprintf(fp,"%d %d %f\n",i+1,a[i],b[i]);

}
max1=a[0],min1=a[0];
for(i=0;i<99;i++)
{

if(max1<=a[i+1])
{max1=a[i+1];}


sum1=sum1+a[i];

if(min1>a[i+1])
{
min1=a[i+1];
}
}

max2=b[0],min2=b[0];
for (i=0;i<99;i++)
{

if(max2<=b[i+1])
{max2=b[i+1];}
if(min2>=b[i+1])
{min2=b[i+1];}
sum2=sum2+b[i];
}

fprintf(fp,"%s %d %f\n","max",max1,max2);
fprintf(fp,"%s %d %f\n","min",min1,min2);
fprintf(fp,"%s %f %f\n","ave",sum1/100,sum2/100);
fclose(fp);
}
else
{
fclose(fp);
}
return 0;
}
